#include <iostream>
#include <list>
#include <mutex>
using namespace std;

typedef uint8 RANK;
// 伪代码结构体
typedef struct
{
    uint16 number;
    uint16 rank;
    std::string info;
} Track;
class TrackContainer
{
public:
    TrackContainer() = default;
    ~TrackContainer() = default;
    TrackContainer(const Track &) = delete;
public:
    // 插入轨迹
    void insert_track(Track &track)
    {
        if (m_track.size() < 8)
        {
            std::lock_guard<std::mutex> guard(m_mutex);
            m_track.emplace_front(track);
        }
        return;
    }
    
    // 根据id删除轨迹
    void delete_track(RANK num)
    {
        std::list<Track>::iteractor it = m_track.begin();
        int start = 0;
        while (it != m_track..end())
        {
            if (start == (num - 1))
            {
                std::lock_gua rd<std::mutex> guard(m_mutex);
                it = m_track.erase(it)
            }
            else
            {
                it++;
                num++;
            }
        }
        return;
    }
    // 清除所有轨迹
    void clear_all()
    {
        std::lock_guard<std::mutex> guard(m_mutex);
        m_track.clear();
        return;
    }
private:
    std::list<Track> m_track;
    std::mutex m_mutex;
}

